package de.lehmann.sudoku.userInterface.graphical;

import javax.swing.JPanel;
import java.awt.GridLayout;
import java.awt.Color;


public class SBox extends JPanel {
	public static final int OFFSET = 1;
	private static final long serialVersionUID = 1L;

	protected final int X;
	protected final int Y;
	private STile[] tiles;
	
	protected SBox(int xPos, int yPos) {
		X = xPos;
		Y = yPos;
		
		int height = 3/**((SGrid)getParent()).HEIGHT*/;
		int width = 3/**((SGrid)getParent()).WIDTH*/;
		
		setForeground(Color.BLACK);
		setBackground(Color.GRAY);
		setLayout(new GridLayout(0, 3 /**((SGrid)getParent()).WIDTH*/, OFFSET, OFFSET));
		
		tiles = new STile[width*height];
		int i = 0;
		for(int y = 0; y < height; y++){
			for(int x = 0; x < width; x++){
				tiles[i] = new STile((xPos*width)+x, (yPos*height)+y);
				add(tiles[i]);
				i++;
			}
		}
	}
	
	protected void adaptFont() {
		for(int i = tiles.length-1; i >= 0; i--){
			tiles[i].adaptFont();
		}
	}

}
